<%@ page import="psl.*" %>
<%@ page import="java.util.*" %>
<%@ page import="extra.CountryList" %>
<%@ page import="extra.HTMLServices" %>
<%
    System.out.println ("Restart : CountryList.jsp");

    UserSession moUserSession = (UserSession) session.getAttribute ("UserSession");
    CountryList moCountryList = (extra.CountryList) moUserSession.getCurrentPage ();

    String msCountryCd = moCountryList.msCountryCd == null ? "" : moCountryList.msCountryCd;
    String msCountryName = moCountryList.msCountryName == null ? "" : moCountryList.msCountryName;
    String msGroupCd = moCountryList.msGroupCd == null ? "" : moCountryList.msGroupCd;
    String msZoneCd = moCountryList.msZoneCd == null ? "" : moCountryList.msZoneCd;
    String msRestricted = moCountryList.msRestricted == null ? "" : moCountryList.msRestricted;

    int miCurrentPage = moCountryList.miCurrentPage;
    ArrayList mvRows = moCountryList.mvRows;

    int miStartRow = 0;
    int miEndRow = 0;
    int miRows = 0;

    if (mvRows != null)
    {
        miRows = mvRows.size ();
        miStartRow = miCurrentPage * 10;
        miEndRow = miStartRow + 10;
        if (miEndRow > mvRows.size ()) miEndRow = mvRows.size ();
    }
%>

<html>
<head>
	<title>Country List</title>
<%--
	<link href='Stylesheet.css' type='text/css' rel='stylesheet'>
--%>
    <script type='text/javascript' src='Controller.js' language='JavaScript'></script>
</head>
<body>
<div class='navigation'>
    <button style='height:25px;width:150px;' class='imageButtonHead' type='button'>
        <nobr>Country</nobr>
    </button>
</div>
<div class='tab-pane'>
<div class='tab-page'>
<form name='DataForm' onsubmit='return false;'>
<input type='hidden' name='action_fld'>
<table border=0>
    <tr>
        <td>
            <fieldset>
                <legend>Search Criteria</legend>
                <table border=0 cellpadding=0>
                    <tr>
                        <td><label accesskey='F' for='country_cd'>Code:&nbsp;</label></td>
                        <td><input id='country_cd' name='country_cd' maxlength=4 size=4 type='text'
                                   value='<%=msCountryCd%>'/>
						</td>
					</tr>
					<tr>
						<td><label accesskey='F' for='country_name'>Name:&nbsp;</label></td>
						<td><input id='country_name' name='country_name' maxlength=50 size=50 type='text'
									  value='<%=msCountryName%>'/></td>
					</tr>
					<tr>
						<td><label accesskey='F' for='country_group_cd'>Country Group:&nbsp;</label></td>
						<td><input id='country_group_cd' name='country_group_cd' maxlength='4' size='4' type='text'
									  value='<%=msGroupCd%>'>
						</td>
					</tr>
					<tr>
						<td><label accesskey='F' for='zone_cd'>Zone:&nbsp;</label></td>
						<td><input id='zone_cd' name='zone_cd' maxlength='4' size='4' type='text' value='<%=msZoneCd%>'>
						</td>
					</tr>
					<tr>
						<td><label accesskey='F'>Restricted:&nbsp;</label></td>
						<td><select name='restricted'>
							<option value=''></option>
							<option value='Y' <%="Y".equals(msRestricted) ? "selected" : ""%>>Yes</option>
							<option value='N' <%="N".equals(msRestricted) ? "selected" : ""%>>No</option>
						</select></td>
					</tr>
				</table>
				<table border=0>
					<tr>
						<td>
							<button style='height:25px;width:65px;' onMouseOver="className='activeImageButton';"
									  onMouseOut="className='imageButton';" class='imageButton' id='search'
									  onclick="performSearch();" accesskey='S' type='button'>
								<u>S</u>earch
							</button>
						</td>
					</tr>
				</table>
			</fieldset>
		</td>
	</tr>
</table>
<table border=0>
	<tr>
		<td>
			<button  onMouseOver="className='activeImageButton';"
					  onMouseOut="className='imageButton';" class='imageButton' id='new' onclick="newRecord();"
					  accesskey='N' type='button'>
				<u>N</u>ew
			</button>
		</td>
		<td>
			<button style='height:25px;width:65px;' onMouseOver="className='activeImageButton';" disabled='true'
					  onMouseOut="className='imageButton';" class='imageButton' id='edit' onclick="editRecord();"
					  accesskey='E' type='button'>
				<u>E</u>dit
			</button>
		</td>
		<td>
			<button style='height:25px;width:65px;' onMouseOver="className='activeImageButton';" disabled='true'
					  onMouseOut="className='imageButton';" class='imageButton' id='copy' onclick="copyRecord();"
					  accesskey='y' type='button'>
				Cop<u>y</u></button>
		</td>
		<td>
			<button style='height:25px;width:65px;' onMouseOver="className='activeImageButton';" disabled='true'
					  onMouseOut="className='imageButton';" class='imageButton' id='delete'
					  onclick="deleteRecord();" accesskey='D' type='button'>
				<u>D</u>elete
			</button>
		</td>
		<td>
			<button style='height:25px;width:65px;' onMouseOver="className='activeImageButton';"
					  onMouseOut="className='imageButton';" class='imageButton' id='cancel'
					  onclick="performCancel();" accesskey='C' type='button'>
				<u>C</u>ancel
			</button>
		</td>
	</tr>
</table>
<table border="0" width=98% class='itemNavigation'>
	<tr>
		<td>
			<%
                int liPages = miRows / 10;
                String lsText = HTMLServices.getPageSelection (liPages, miCurrentPage, 10, miRows);
                out.write (lsText);
            %>
		</td>
	</tr>
</table>
<div class='searchResults'>
	<table width=100% border=0>
		<thead>
			<tr>
				<th width=15>&nbsp;</th>
				<th><a href='javascript:sortByColumn(0);'>Code</a></th>
				<th><a href='javascript:sortByColumn(1);'>Name</a></th>
				<th><a href='javascript:sortByColumn(2);'>Group</a></th>
				<th><a href='javascript:sortByColumn(3);'>Zone</a></th>
			</tr>
		</thead>
		<tbody>
			<%
				for (int liRow = miStartRow; liRow < miEndRow; liRow++)
				{
					String[] laRow = (String[])mvRows.get(liRow);
			%>
			<tr border="0" height=17 id='row<%=liRow%>' class=''>
				<td onClick='selectRow(<%=liRow%>);'></td>
				<td  class='' onclick='selectRow(<%=liRow%>);' onDblClick='editRecord();'><%=laRow[0]%>
				</td>
				<td class='' onclick='selectRow(<%=liRow%>);' onDblClick='editRecord();'><%=laRow[1]%>
				</td>
				<td class='' onclick='selectRow(<%=liRow%>);' onDblClick='editRecord();'><%=laRow[2]%>
				</td>
				<td class='' onclick='selectRow(<%=liRow%>);' onDblClick='editRecord();'><%=laRow[3]%>
				</td>
			</tr>
			<%
				}
			%>
		</tbody>
	</table>
</div>
</form>
</div>
</div>
</body>
</html>